<!DOCTYPE html>
<title>String handling of NULL (U+0000) characters</title>
<script src="../../resources/js-test.js"></script>
<script>
description("Test that embedded NULL (U+0000) characters don't truncate strings.");
window.jsTestIsAsync = true;

function errorCallback(transaction, error)
{
    testFailed("Database error code: " + error.code + ", message: " + error.message);
}

var string = "foo\0bar";
var result;

function runTest()
{
    if (window.testRunner)
        testRunner.clearAllDatabases();

    openDatabase("NullCharacterTest", "1.0", "Database for null characters test", 1,
        function(db) {
            db.readTransaction(function(t) {
                t.executeSql("SELECT ? AS string", [string], function(t, data) {
                    result = data.rows[0].string;
                    shouldBeEqualToString("result", string);
                    finishJSTest();
                }, errorCallback);
            }, errorCallback);
        });
}

runTest();
</script>
